# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-openpyxl
_pkgreal=openpyxl
pkgver=3.1.2
pkgrel=4
pkgdesc="A Python library to read/write Excel 2010 xlsx/xlsm files"
url="https://foss.heptapod.net/openpyxl/openpyxl"
arch="noarch"
license="MIT"
depends="python3 py3-lxml py3-pandas py3-pillow"
checkdepends="py3-pytest-xdist py3-tox"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://foss.heptapod.net/openpyxl/openpyxl/-/archive/$pkgver/openpyxl-$pkgver.tar.gz
	$pkgname-pytest8.patch::https://foss.heptapod.net/openpyxl/openpyxl/-/commit/517ce7d21194da275f8083fa2fd7de6977dc7e95.patch"
builddir="$srcdir/$_pkgreal-$pkgver"

case "$CARCH" in
# several test fails on ppc64le | skip for now
ppc64le) options="$options !check" ;;
# some tests raise NotImplementedError on ARM, FIXME
aarch64|arm*) options="$options !check" ;;
esac

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	local ignore=
	case "$CARCH" in
		riscv64)
			ignore="$ignore --ignore=openpyxl/chart/tests/test_chart.py" # NotImplementedError
			ignore="$ignore --ignore=openpyxl/drawing/tests/test_spreadsheet_drawing.py" # FileNotFoundError
			;;
	esac
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -n auto $ignore
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
661045ad4aa1ce4c2493c9070dad844fa7e213156e6b19dfed9d455abb3ab1a06691e141b4b6d851fb852b3bd4c8861eb6e1bbe0108eb28835d024eee4a7aa3b  py3-openpyxl-3.1.2.tar.gz
bb9ca4910743eb66870f4e9d8ff1ee18e54d042a4a638b2d49dd2677b256caa19f454c66b2dfe3601adff132159ae4e998363814117dba2b0cf8e0b33a966a44  py3-openpyxl-pytest8.patch
"
